package com.finupgroup.postloan.generator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Properties文件读取工具
 *
 * @author YueQingwei
 * @since 2018-04-10
 */
public class PropUtils {

    private static final Logger LOGGER = LoggerFactory.getLogger(PropUtils.class);

    private static Properties properties = new Properties();

    static {
        InputStream inputStream = PropUtils.class.getResourceAsStream("/config.properties");
        try {
            properties.load(inputStream);
        } catch (IOException e) {
            LOGGER.error("Could not find properties file at the classpath", e);
        }
    }

    private PropUtils() {
        throw new IllegalStateException("Utility class");
    }

    public static String get(String name) {
        return properties.getProperty(name);
    }

    public static boolean getBoolean(String name) {
        String value = get(name);
        return Boolean.parseBoolean(value);
    }
}
